package cn.hpclub.server.model;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

/**
 * @FileName: Opportunity.java
 * @Author zhl
 * @Description:商机管理数据实体类
 * @Date 2016年7月4日 下午2:56:57
 * @CopyRight ZTE Corporation
 */
@TableBind(tableName = "opportunity")
public class Opportunity extends Model<Opportunity>{

    private static final Logger     logger                   = LoggerFactory.getLogger(Opportunity.class);
    private static final long       serialVersionUID         = -3719338752470759887L;
    public static final Opportunity dao                      = new Opportunity();

    public static String            ID                       = "id";

    public static String            PRE_BUSI_ID              = "PRE_BUSI_ID";

    public static String            PRE_BUSI_NAME            = "PRE_BUSI_NAME";

    public static String            CUST_GRP_NAME            = "CUST_GRP_NAME";

    public static String            CUST_CONT_NAME           = "CUST_CONT_NAME";

    public static String            CUST_CONT_PHONE          = "CUST_CONT_PHONE";

    public static String            CUST_CONT_TEL            = "CUST_CONT_TEL";

    public static String            CUST_CONT_ADDR           = "CUST_CONT_ADDR";

    public static String            CITY_GROUP_ID            = "CITY_GROUP_ID";

    public static String            CITY_GROUP_NAME          = "CITY_GROUP_NAME";

    public static String            COUNTY_GROUP_ID          = "COUNTY_GROUP_ID";

    public static String            COUNTY_GROUP_NAME        = "COUNTY_GROUP_NAME";

    public static String            BUSI_TYPE                = "BUSI_TYPE";

    public static String            BUSI_CLASS               = "BUSI_CLASS";

    public static String            BUSI_TYPE_NAME           = "BUSI_TYPE_NAME";

    public static String            BUSI_CLASS_NAME          = "BUSI_CLASS_NAME";

    public static String            BUSI_REQ_DESC            = "BUSI_REQ_DESC";

    public static String            PRE_CALL_DAY             = "PRE_CALL_DAY";

    public static String            PRE_CALL_TIME            = "PRE_CALL_TIME";

    public static String            CALL_LIMIT_DAY           = "CALL_LIMIT_DAY";

    public static String            CHAN_ID                  = "CHAN_ID";

    public static String            REMARK                   = "REMARK";

    public static String            UNIT_ID                  = "UNIT_ID";

    public static String            ALL_MOBILE_USER_TOTOAL   = "ALL_MOBILE_USER_TOTOAL";

    public static String            CHINA_MOBLIE_USER_TOTOAL = "CHINA_MOBLIE_USER_TOTOAL";

    /**
     * 获取列表
     *
     * @param pageNumber
     * @param pageSize
     * @return
     */
    public Page<Record> getList(int pageNumber, int pageSize, String PRE_BUSI_ID, String PRE_BUSI_NAME){
        String sqlExceptSelect = "from opportunity where 1=1 ";
        if(StrKit.notBlank(PRE_BUSI_ID)){
            sqlExceptSelect += " AND PRE_BUSI_ID like '%" + PRE_BUSI_ID + "%'";
        }
        if(StrKit.notBlank(PRE_BUSI_NAME)){
            sqlExceptSelect += " AND PRE_BUSI_NAME like '%" + PRE_BUSI_NAME + "%'";
        }
        logger.debug("sql = select * " + sqlExceptSelect);
        return Db.paginate(pageNumber, pageSize, "select *", sqlExceptSelect);
    }
}
